package com.msmall.community.admin.action;

import com.msmall.base.action.HTMLBaseAction;
import com.msmall.base.util.ConstantUrl;
import com.msmall.community.klg.model.Article;
import com.msmall.community.klg.service.ArticleManager;

public class ArticleAction extends HTMLBaseAction{
	
	private static final long serialVersionUID = 8728256152706181301L;

	private Long articleid;
	
	private Long parentType;
	private Long valueType;
	
	private Article article;
	
	private ArticleManager articleManager;

	public String execute(){
		page.setClazz(Article.class);
		page.setPageSize(10);
		articleManager.getPagination(page);
		page.setUrl(ConstantUrl.ADMIN_KLG_ARTICLE_INDEX);
		return "success";
	}
	
	public String create(){
		article = null;
		return "success";
	}
	public String update(){
		try {
			article = (Article) articleManager.getArticle(articleid);
		} catch (Exception e) {
			log.debug(e);
		}
		return "success";
	}

	public String save(){
		try {
			articleManager.saveArticle(article, valueType, getUserid(), getUserAgentType());
		} catch (Exception e) {
			log.debug(e);
		}
		return "success";
	}
	
	public Long getArticleid() {
		return articleid;
	}

	public void setArticleid(Long articleid) {
		this.articleid = articleid;
	}

	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

	public ArticleManager getArticleManager() {
		return articleManager;
	}

	public void setArticleManager(ArticleManager articleManager) {
		this.articleManager = articleManager;
	}

	public Long getParentType() {
		return parentType;
	}

	public void setParentType(Long parentType) {
		this.parentType = parentType;
	}

	public Long getValueType() {
		return valueType;
	}

	public void setValueType(Long valueType) {
		this.valueType = valueType;
	}
}
